<?php

namespace app\index\validate;

use think\Validate;

class Reply extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */
	protected $rule = [
        'id' => 'require|gt:0|token',
        'topic_id' => 'require|gt:0',
        'content' => 'require|length:3,200|token',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'id.require' => 'ID不能为空',
        'id.gt' => 'ID错误',
        'id.token' => '表单令牌不正确',
        'topic_id.require' => '所属话题不能为空',
        'topic_id.gt' => '所属话题不存在',
        'content.require' => '评论正文不能为空',
        'content.length' => '标题长度必须在3-200个字符之间',
        'content.between' => '表单令牌不正确',
    ];

    protected $scene = [
        'create_or_update'  =>  ['topic_id', 'content'],
        'delete'  =>  ['id'],
    ];
}
